package com.moli.iov.third.remote.impl;

import com.moli.iov.rest.RestResponse;
import com.moli.iov.third.invocation.op.CommandNoticeHandler;
import com.moli.iov.third.invocation.op.CreateUserHandler;
import com.moli.iov.third.invocation.op.ModifyPasswordHandler;
import com.moli.iov.third.invocation.op.ModifyUserHandler;
import com.moli.iov.third.model.dto.op.CommandNoticeDto;
import com.moli.iov.third.model.dto.op.CreateUserDto;
import com.moli.iov.third.model.dto.op.ModifyPasswordDto;
import com.moli.iov.third.model.dto.op.ModifyUserDto;
import com.moli.iov.third.remote.IUserOpRemoteService;
import java.io.IOException;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * <p>
 * 用户业务
 * </p>
 *
 * @author zql
 * @since 2019/10/10 10:47
 */
@Slf4j
@Service(group = "${service.group}")
public class UserOpRemoteServiceImpl implements IUserOpRemoteService {

  @Autowired
  private CreateUserHandler createUserHandler;

  @Autowired
  private ModifyUserHandler modifyUserHandler;

  @Autowired
  private ModifyPasswordHandler modifyPasswordHandler;

  @Autowired
  private CommandNoticeHandler commandNoticeHandler;

  /**
   * 添加用户
   * @param userDto
   * @return
   */
  @Override
  public RestResponse createUser(CreateUserDto userDto) throws Exception {
      createUserHandler.createUser(userDto);
      return RestResponse.success();
  }

  /**
   * 修改用户
   * @param modifyUserDto
   * @return
   */
  @Override
  public RestResponse modifyUser(ModifyUserDto modifyUserDto) throws IOException {
    modifyUserHandler.modifyUser(modifyUserDto);
    return RestResponse.success();
  }

  /**
   * 修改密码
   * @param modifyPasswordDto
   * @return
   */
  @Override
  public RestResponse modifyPassword(ModifyPasswordDto modifyPasswordDto) throws IOException {
    modifyPasswordHandler.modifyPassword(modifyPasswordDto);
    return RestResponse.success();
  }

  /**
   * 重置密码
   * @param modifyPasswordDto
   * @return
   */
  @Override
  public RestResponse resetPassword(ModifyPasswordDto modifyPasswordDto) throws IOException {
    modifyPasswordHandler.modifyPassword(modifyPasswordDto);
    return RestResponse.success();
  }

  /**
   * 控车通知
   * @param commandNoticeDto
   * @return
   */
  @Override
  public RestResponse controlCommandNotice(CommandNoticeDto commandNoticeDto) throws IOException {
    commandNoticeHandler.Notice(commandNoticeDto);
    return RestResponse.success();
  }
}
